package robotleMvc.ui.buildEdit
{
	import com.net.AssetData;
	import com.ui.cell.Cell;
	import com.ui.cell.CellData;
	import com.ui.controls.Button;
	import com.ui.data.ButtonData;
	
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	import robotleMvc.frameworks.buildEdit.event.BuildEditEvent;
	import robotleMvc.ui.SkinType;
	import robotleMvc.ui.TextUtil;
	
	import test.vo.StatVO;


	public class BuildEditCell extends Cell
	{
		private var _makeShadowBut:Button;
		private var _buildName:TextField;
		private var _statVO:StatVO;
		private var _buildX:TextField;
		private var _buildZ:TextField;

		public function BuildEditCell(data:CellData)
		{
			super(data);
			addTexts();
			addButtons();
			addEvents();
		}
		
		private function addEvents():void
		{
			_makeShadowBut.addEventListener(MouseEvent.CLICK,_makeShadowButClik);
		}
		
		protected function _makeShadowButClik(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			var buildEditEvent:BuildEditEvent=new BuildEditEvent(BuildEditEvent.BUILD_EDIT_CELL_CHOOSE);
			buildEditEvent.chooseStatVO=_statVO;
			parent.parent.dispatchEvent(buildEditEvent);
			
		}
		
		private function addTexts():void
		{
			_buildName=TextUtil.getTextField();
			_buildName.x=0+40
			addChild(_buildName);

			_buildX=TextUtil.getTextField();
			_buildX.x=50+100;
			addChild(_buildX);

			_buildZ=TextUtil.getTextField();
			_buildZ.x=100+100
			addChild(_buildZ);
			

		}

		private function addButtons():void
		{
			var data:ButtonData=new ButtonData();
			data.x=250;
			data.upAsset=new AssetData(SkinType.BUTTON_UP);
			data.downAsset=new AssetData(SkinType.BUTTON_DOWN);
			data.overAsset=new AssetData(SkinType.BUTTON_OVER);
			_makeShadowBut=new Button(data);
			_makeShadowBut.htmlText="选择";
			addChild(_makeShadowBut);
			_makeShadowBut.y=3;

		}

		override public function set source(value:*):void
		{
			_statVO=value as StatVO
			if (_statVO)
			{
				_buildName.htmlText=String(_statVO.et);
				_buildX.htmlText=String(_statVO.x);
				_buildZ.htmlText=String(_statVO.z);
			}
		}
	}
}
